import requests
import numpy as np
url = 'https://q.stock.sohu.com/hisHq?code=cn_{}&start={}&end={}'

rsp = requests.get(url.format('002407','20210701','20210721'))
#print(rsp.json())
datas = rsp.json()[0]['hq']
"""
日期,
今日开盘价,
今日收盘价,
涨跌幅度，
涨跌百分比,
今日最低价,
今日最高价，
今日成交股票手数,
今日成交金额(单位：万)
换手率
"""
end_prices = [float(u[2]) for u in datas]
mean5 = np.mean(end_prices[:5])
mean10 = np.mean(end_prices[:10])
mean20 = np.mean(end_prices[:20])
print(mean5,mean10,mean20)
